package com.lord.otter.component.tools.business.chain;


import lombok.Data;

import java.util.Date;
import java.util.UUID;

@Data
public class BusinessHandlerLog {

    private String id;

    private String execId;

    private Integer execSeq;

    private Date execTime;

    private String handlerName;

    private String afterExecContext;

    private BusinessHandlerStatus status;

    private String command;

    private String errorMessage;

    private String errorStack;


    public static BusinessHandlerLog create(String execId, Integer execSeq, String handlerName, String afterExecContext,
                                            BusinessHandlerStatus status, String command, String errorMessage, String errorStack) {

        BusinessHandlerLog log = new BusinessHandlerLog();
        log.setId(UUID.randomUUID().toString());
        log.setExecId(execId);
        log.setExecSeq(execSeq);
        log.setHandlerName(handlerName);
        log.setAfterExecContext(afterExecContext);
        log.setStatus(status);
        log.setCommand(command);
        log.setExecTime(new Date());
        log.setErrorMessage(errorMessage);
        log.setErrorStack(errorStack);
        return log;
    }

}
